package doublePointer;

public class IsSubString {
    public boolean isSubsequence(String s, String t) {
        int p1 = 0,p2 = 0; // 双指针初始都指向两个字符的首字母
        int length1 = s.length(),length2 = t.length();
        while(p1 < length1 && p2 < length2){
            //匹配成功
            if(s.charAt(p1) == t.charAt(p2)){
                p1++;
                p2++;
            }else{
                p2++;
            }
        }
        if(p1 < length1){
            return false;
        }else{
            return true;
        }
    }
}
